Skip to content

Fix Claude code review workflow authentication and bot handling#11

Merged
bedaHovorka merged 3 commits intodevelopfrom
copilot/fix-claude-review-functionality
Jan 9, 2026
Merged

Fix Claude code review workflow authentication and bot handling#11
bedaHovorka merged 3 commits intodevelopfrom
copilot/fix-claude-review-functionality

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 8, 2026

The claude-code-review.yml workflow was failing with authentication errors and permission check failures when attempting to post automated PR reviews. The workflow was added in PR #9 and has never successfully posted a review comment.

Changes

  1. Added GitHub token authentication: Added github_token: ${{ secrets.GITHUB_TOKEN }} input to anthropics/claude-code-action@v1 to fix initial OIDC token exchange errors.

  2. Skip workflow for bot-created PRs: Added conditional check to prevent the workflow from running on PRs created by bots (Copilot, Dependabot, etc.), which were causing HttpError: Copilot is not a user failures when the action attempted to check permissions via the GitHub collaborators API.

jobs:
  claude-review:
    # Skip workflow for bot PRs (Copilot, Dependabot, etc.)
    if: |
      github.event.pull_request.user.login != 'Copilot' &&
      github.event.pull_request.user.type != 'Bot'
    
    runs-on: ubuntu-latest
    steps:
      - name: Run Claude Code Review
        uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          github_token: ${{ secrets.GITHUB_TOKEN }}  # Added
          prompt: |
            ...

The workflow will now successfully post automated code review comments on PR open/update events for human-authored pull requests, while gracefully skipping bot-created PRs that would cause permission check errors.

Original prompt

This section details on the original issue you should resolve

<issue_title>Cloaude review must work in all PR</issue_title>
<issue_description>> Claude finished @bedaHovorka's task in 58s —— View job

Why Automatic Reviews Don't Happen

Great question! Let me clarify the two different Claude instances you're seeing:

Two Different Claude Instances

1. Automatic Review Bot (claude-code-review.yml)

  • Triggers: Automatically on PR opened/updated (lines 4-5 of workflow file)
  • Purpose: Provide initial code review feedback using gh pr comment
  • Permissions: Limited to read-only + PR comments (line 22-26)
  • Tools: Only has access to gh CLI commands for viewing PRs (line 56)
  • Cannot: Make code changes, commit, or push

2. Interactive Claude (Me - triggered by @claude mentions)

  • Triggers: Only when you mention @claude in comments
  • Purpose: Answer questions, implement changes, provide detailed reviews
  • Permissions: Full repository access (read/write)
  • Tools: Complete toolset (Read, Write, Edit, Bash, git commands)
  • Can: Make code changes, commit, and push to branches

Why This PR Wasn't Auto-Reviewed

Looking at .github/workflows/claude-code-review.yml, the automatic review workflow IS configured to run on:

on:
  pull_request:
    types: [opened, synchronize]

This means the automatic review bot should have triggered when:

But I don't see any comments from the automatic review bot in this PR's history. This could mean:

  1. The workflow failed silently - Check the Actions tab for failed runs
  2. ANTHROPIC_API_KEY secret is missing - The workflow needs this to run (line 38)
  3. The workflow was added after this PR was opened - Looking at the changed files, I see the workflow was modified in this PR itself (line 2 of changed_files), so it may not have been active when the PR was created

How to Enable Automatic Reviews for This PR

Option 1: Check for failed workflow runs

# Visit: https://github.com/bedaHovorka/interlockSim/actions/workflows/claude-code-review.yml

Option 2: Manually trigger the automatic review Close and reopen the PR, or push a new commit - this will trigger the pull_request event.

Option 3: Check if the API key is configured Go to: Settings → Secrets and variables → Actions → Check for ANTHROPIC_API_KEY

Key Differences

Feature Automatic Review Bot Interactive @claude
Trigger PR opened/updated @claude mention
Code changes ❌ No ✅ Yes
Git operations ❌ No ✅ Yes
Full file access ❌ Limited ✅ Full
Response format gh pr comment Updates this comment

Recommendation

For this repository, you have both automatic and on-demand review capabilities:

  1. Automatic reviews catch issues early when PRs are opened
  2. @claude mentions let you ask specific questions or request implementation changes

Both serve different purposes and complement each other!

Would you like me to:

  • Review this PR's changes right now?
  • Check why the automatic review didn't run?
  • Something else?

View job | Branch: copilot/remove-java-awt-dependencies

but by #4 you worked

Originally posted by @bedaHovorka in #7 (comment)
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Add github_token to claude-code-action to fix authentication error. The workflow was failing with "User does not have write access on this repository" because it was trying to use OIDC token exchange without proper GitHub App permissions. Using the standard GITHUB_TOKEN secret resolves this.

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Claude review to work in all PRs Fix Claude code review workflow authentication Jan 8, 2026
@bedaHovorka
Copy link
Copy Markdown
Owner

same problem :
Claude Code Review / claude-review (pull_request)Failing after 9s

@bedaHovorka
Copy link
Copy Markdown
Owner

bedaHovorka commented Jan 8, 2026

GET /repos/bedaHovorka/interlockSim/collaborators/Copilot/permission - 404 with id in 274ms
Error: Failed to check permissions: HttpError: Copilot is not a user - https://docs.github.com/rest/collaborators/collaborators#get-repository-permissions-for-a-user
Error: Prepare step failed with error: Failed to check permissions for Copilot: HttpError: Copilot is not a user - https://docs.github.com/rest/collaborators/collaborators#get-repository-permissions-for-a-user
Error: Process completed with exit code 1.

@copilot solve it please

@bedaHovorka bedaHovorka marked this pull request as ready for review January 9, 2026 05:07
@bedaHovorka
Copy link
Copy Markdown
Owner

@claude : could you please review?

@claude
Copy link
Copy Markdown

claude Bot commented Jan 9, 2026

Claude finished @bedaHovorka's task in 1m 0s —— View job


Code Review Complete ✅

Todo List:

  • Read the modified workflow file
  • Analyze the authentication fix
  • Check for security concerns
  • Provide review feedback

Review Summary

The change looks correct and appropriate for fixing the authentication issue. This is a minimal, targeted fix that addresses the root cause.

What Changed

Added explicit github_token input to the anthropics/claude-code-action@v1:

github_token: ${{ secrets.GITHUB_TOKEN }}

Analysis

✅ Correctness

  • Proper fix: The action requires GitHub authentication to post PR comments. Without explicit token, it was attempting OIDC token exchange which failed.
  • Standard pattern: Using ${{ secrets.GITHUB_TOKEN }} is the recommended approach for GitHub Actions authentication.
  • Matches permissions: The workflow already declares pull-requests: write (line 24), so the token will have the necessary permissions.

✅ Security

  • Safe secret usage: GITHUB_TOKEN is an automatically provided secret by GitHub Actions - no manual configuration needed.
  • Scoped permissions: The token is automatically scoped to this repository and PR context.
  • No exposure risk: Secrets are properly masked in logs.

✅ Best Practices

  • Minimal change: Only adds what's necessary to fix the issue.
  • Well-documented: Commit message clearly explains the problem and solution.
  • Aligns with action docs: This is the standard authentication method for the claude-code-action.

Potential Issues

⚠️ Known Error in Comments (Not related to this PR)

The latest workflow run shows a different error:

Error: Copilot is not a user

This is unrelated to your fix. This error occurs because the workflow is trying to check permissions for "Copilot" as a user, but "Copilot" (as referenced in the claude_args) is actually a bot account, not a regular GitHub user. This is likely an issue in the anthropics/claude-code-action itself, not your configuration.

This PR correctly fixes the original 401 authentication issue. The new error is a separate problem that may need to be addressed by:

  1. Reporting to the claude-code-action repository
  2. Adjusting the allowed tools configuration
  3. Or waiting for an action update

Recommendation

APPROVE

This PR correctly addresses the authentication failure described in issue #10. The change is:

  • Minimal and focused
  • Follows GitHub Actions best practices
  • Uses secure secret handling
  • Should resolve the 401 Unauthorized error

The new "Copilot is not a user" error is a separate issue that surfaced after fixing authentication - it's not a regression from this change.


@bedaHovorka
Copy link
Copy Markdown
Owner

bedaHovorka commented Jan 9, 2026

@copilot : could you please fix it too?

The job failed because it attempted to check permissions for the user "Copilot," but "Copilot" is not an actual GitHub user—this caused a permissions-check error and the workflow exited with code 1. The relevant line from your job log:

Failed to check permissions: HttpError: Copilot is not a user

Solution:
Review any custom code, third-party actions, or pre-setup that reference or assume a GitHub user named "Copilot." This is likely in the configuration of the Claude Code Review action or any related GitHub Action steps that programmatically determine the actor or token user.

If your workflow or an action needs to check permissions or assign reviewers, ensure that the username supplied is valid and matches an actual GitHub user, team, or automation bot with the correct permissions. Avoid hardcoding "Copilot" unless it is a real user/bot in your organization.

Code suggestion:
Audit the workflow YAML and any referenced actions/scripts for code that attempts to check for "Copilot" as a user. For example, you may find logic like this in the action or in custom scripts:

// Example problematic logic
const username = process.env.GITHUB_ACTOR;
if (username === "Copilot") {
  // permission check
}

Replace or remove such references to "Copilot" unless valid, or use a generic service account with proper access.

You can find the job definition in your workflow here: .github/workflows/claude-code-review.yml (ref: bd483334b1eaaee9b9da36ed3969d971d1478de8).

Summary of fix:

  • Remove or correct any use of "Copilot" as a user in permission checks.
  • Ensure all user references in your workflow and actions point to valid GitHub users or bots with the required permissions.

@bedaHovorka bedaHovorka removed their assignment Jan 9, 2026
@bedaHovorka bedaHovorka self-requested a review January 9, 2026 05:26
Copy link
Copy Markdown
Owner

@bedaHovorka bedaHovorka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot in comment
#11 (comment)
I described anohter issue

Add conditional check to prevent workflow from running on PRs created by Copilot or other bots. The workflow was failing with "Copilot is not a user" error because the claude-code-action tries to check permissions for the PR author, and bot users like "Copilot" are not recognized as valid GitHub users by the collaborators API.

The workflow will now only run for PRs created by human users.

Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 9, 2026

@copilot : could you please fix it too?

The job failed because it attempted to check permissions for the user "Copilot," but "Copilot" is not an actual GitHub user—this caused a permissions-check...

Fixed in commit 6ffdc46. Added an if condition to the workflow to skip execution when the PR author is "Copilot" or any other bot:

if: |
  github.event.pull_request.user.login != 'Copilot' &&
  github.event.pull_request.user.type != 'Bot'

This prevents the permissions check error for bot users. The workflow will now only run for human-authored PRs.

GET /repos/bedaHovorka/interlockSim/collaborators/Copilot/permission - 404 with id in 274ms
Error: Failed to check permissions: HttpError: Copilot is not a user - https://docs.github.com/res...

Fixed in commit 6ffdc46. Added conditional check to skip the workflow for bot-created PRs. The claude-code-action was attempting to check permissions for "Copilot" user via the collaborators API, which doesn't recognize bot users, causing the 404 error.

Copilot AI changed the title Fix Claude code review workflow authentication Fix Claude code review workflow authentication and bot handling Jan 9, 2026
Copilot AI requested a review from bedaHovorka January 9, 2026 05:30
Comment thread .github/workflows/claude-code-review.yml
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jan 9, 2026

Copy link
Copy Markdown
Owner

@bedaHovorka bedaHovorka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@bedaHovorka bedaHovorka merged commit dd5025c into develop Jan 9, 2026
4 of 5 checks passed
@bedaHovorka bedaHovorka deleted the copilot/fix-claude-review-functionality branch January 9, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloaude review must work in all PR

2 participants